//
// This file is part of an OMNeT++/OMNEST simulation example.
//
// Copyright (C) 2003 Ahmet Sekercioglu
// Copyright (C) 2003-2008 Andras Varga
//
// This file is distributed WITHOUT ANY WARRANTY. See the file
// `license' for details on this and other legal matters.
//

#include <vector>
#include "FGMessage_m.h"

enum FGMessageType{
	FG_RREQ,
	FG_RREP,
	FG_RERR,
	FG_HELLO,
	FG_RTEST,
	FG_RTEST_ACK
};
class FGMessage : public FGMessage_Base
{
	protected:
  	  std::vector<IPAddress> route;
    public:
      FGMessage(const char *name=NULL, int kind=0) : FGMessage_Base(name,kind) {}
      FGMessage(const FGMessage& other) : FGMessage_Base(other.getName()) {operator=(other);}
      FGMessage& operator=(const FGMessage& other) {
    	  FGMessage_Base::operator=(other);
    	  this->route=other.route;//add by us
    	  return *this;
      }
      virtual FGMessage *dup() const {return new FGMessage(*this);}


      //about vector
      virtual void setRouteArraySize(unsigned int size){}					//not used
      virtual unsigned int getRouteArraySize() const{return route.size();}
      virtual IPAddress& getRoute(unsigned int k){return route.at(k);}
      virtual void setRoute(unsigned int k, const IPAddress& route_var){}	//not used
      virtual void insertMyAddr(IPAddress& ip){route.push_back(ip);}
      virtual IPAddress getAndDeleteLastAddress(){
    	  IPAddress e=route.back();
    	  route.pop_back();
    	  return e;
      }
      //about numHop
      void incNumHop(){numHop_var++;}

};

Register_Class(FGMessage);

EXECUTE_ON_STARTUP(
    cEnum *e = cEnum::find("FGMessageType");
    if (!e) enums.getInstance()->add(e = new cEnum("FGMessageType"));
    e->insert(FG_RREQ, "FG_RREQ");
    e->insert(FG_RREP, "FG_RREP");
    e->insert(FG_RERR, "FG_RERR");
    e->insert(FG_HELLO, "FG_HELLO");
    e->insert(FG_RTEST, "FG_RTEST");
    e->insert(FG_RTEST_ACK, "FG_RTEST_ACK");
);
